package com.yiyahui.project.erp.controller;

import java.util.List;

import com.yiyahui.project.erp.domain.requestVo.YiyaBatchAddResourceShadow;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import com.yiyahui.framework.aspectj.lang.annotation.Log;
import com.yiyahui.framework.aspectj.lang.enums.BusinessType;
import com.yiyahui.project.erp.domain.YiyaResourceShadow;
import com.yiyahui.project.erp.service.IYiyaResourceShadowService;
import com.yiyahui.framework.web.controller.BaseController;
import com.yiyahui.framework.web.domain.AjaxResult;
import com.yiyahui.common.utils.poi.ExcelUtil;
import com.yiyahui.framework.web.page.TableDataInfo;

/**
 * 影像资源Controller
 * 
 * @author yiyahui
 * @date 2020-05-16
 */
@Api("影像资源")
@RestController
@RequestMapping("/erp/shadow")
public class YiyaResourceShadowController extends BaseController
{
    @Autowired
    private IYiyaResourceShadowService yiyaResourceShadowService;
 
    /**
     * 查询影像资源列表
     */
    @ApiOperation("查询影像资源列表")
    @PreAuthorize("@ss.hasPermi('erp:shadow:list')")
    @GetMapping("/list")
    public TableDataInfo list(YiyaResourceShadow yiyaResourceShadow)
    {
        startPage();
        List<YiyaResourceShadow> list = yiyaResourceShadowService.selectYiyaResourceShadowList(yiyaResourceShadow);
        return getDataTable(list);
    }

    /**
     * 导出影像资源列表
     */
    @ApiOperation("导出影像资源列表")
    @PreAuthorize("@ss.hasPermi('erp:shadow:export')")
    @Log(title = "影像资源", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YiyaResourceShadow yiyaResourceShadow)
    {
        List<YiyaResourceShadow> list = yiyaResourceShadowService.selectYiyaResourceShadowList(yiyaResourceShadow);
        ExcelUtil<YiyaResourceShadow> util = new ExcelUtil<YiyaResourceShadow>(YiyaResourceShadow.class);
        return util.exportExcel(list, "shadow");
    }

    /**
     * 获取影像资源详细信息
     */
    @ApiOperation("获取影像资源详细信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, dataType = "Long", paramType = "path")
    @PreAuthorize("@ss.hasPermi('erp:shadow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yiyaResourceShadowService.selectYiyaResourceShadowById(id));
    }

    /**
     * 新增影像资源
     */
    @ApiOperation("新增影像资源")
    @ApiImplicitParam(name = "yiyaResourceShadow", value = "${tableComment}", dataType = "YiyaResourceShadow")
    @PreAuthorize("@ss.hasPermi('erp:shadow:add')")
    @Log(title = "影像资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YiyaResourceShadow yiyaResourceShadow)
    {
        return toAjax(yiyaResourceShadowService.insertYiyaResourceShadow(yiyaResourceShadow));
    }

    /**
     * 修改影像资源
     */
    @ApiOperation("修改影像资源")
    @ApiImplicitParam(name = "yiyaResourceShadow", value = "${tableComment}", dataType = "YiyaResourceShadow")
    @PreAuthorize("@ss.hasPermi('erp:shadow:edit')")
    @Log(title = "影像资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YiyaResourceShadow yiyaResourceShadow)
    {
        return toAjax(yiyaResourceShadowService.updateYiyaResourceShadow(yiyaResourceShadow));
    }

    /**
     * 删除影像资源
     */
    @ApiOperation("删除影像资源")
    @ApiImplicitParam(name = "ids", value = "主键id数组", required = true, dataType = "Long[]", paramType = "path")
    @PreAuthorize("@ss.hasPermi('erp:shadow:remove')")
    @Log(title = "影像资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yiyaResourceShadowService.deleteYiyaResourceShadowByIds(ids));
    }

    /**
     * 批量新增影像资源
     */
    @ApiOperation("批量新增影像资源")
    @Log(title = "影像资源", businessType = BusinessType.INSERT)
    @PostMapping("/batch/add")
    public AjaxResult batchAdd(@RequestBody YiyaBatchAddResourceShadow yiyaBatchAddResourceShadow)
    {
        try {
            return yiyaResourceShadowService.batchInsertYiyaResourceShadow(yiyaBatchAddResourceShadow);
        } catch (Exception e) {
            return AjaxResult.error();
        }
    }
}
